let token;
setInterval(() => {
  token = wx.getStorageSync('token');
}, 500);


const next = (url, routerType, success, fail, complete) => {
  wx[routerType]({
    url,
    success,
    fail,
    complete,
  });
};
const notLogin = () => {
  wx.showModal({
    title: '系统提示',
    content: '尚未登录',
    cancelText: '暂不登录',
    confirmText: '去登录',
    success(res) {
      if (res.confirm) {
        wx.navigateTo({
          url: '/pages/personalCenter/login/login',
        });
      }
    },
  });
};

const go2 = (url, needToken = true, routerType = 'navigateTo', success, fail, complete) => {
  if (!needToken || token) {
    next(url, routerType, success, fail, complete);
  } else {
    notLogin();
  }
};

export default go2;
